﻿<!-- Produkt Actions -->
<div class="row">
	<div class="col-xs-offset-3 col-xs-3 controls">
		<div class="input-group">
			<span class="input-group-addon"><span class="glyphicon glyphicon-search"></span></span>
			<input type="search" class="form-control string" id="produkt_filter" placeholder="Produkte durchsuchen" >
		</div>
	</div>
	<div class="col-xs-offset-4 col-xs-2">		
		<button type="button" class="btn btn-success" onClick="showProdukt(0);">
			<span class="glyphicon glyphicon-plus"></span> <?= HTML::Write("Produkt Hinzufügen"); ?>
		</button>
	</div>
</div>

<!-- Dummy Row für den Abstand -->
<div class="row">&nbsp;</div>

<div class="row">
	<div class="col-xs-3">
		<ul class="list-group select-menu">
		<?php
			foreach ($this->Kategorien as $kategorie)
			{
		?>
			<li id="kat-<?= $kategorie->ID; ?>" class="list-group-item" onClick="selectKategory(<?= $kategorie->ID; ?>);">
				<!-- <span class="badge">14</span> -->
				<span id="kat_<?= $kategorie->ID; ?>_name"><?= HTML::Write($kategorie->Name); ?></span>
			</li>
		<?php
			}
		?>
		</ul>
	</div>
	
	<div id="produkt-list" class="col-xs-3">
	</div>
	
	<div class="col-xs-6">
		<div id="produkt-view" class="panel panel-default">
			
		</div>
	</div>
</div>

<script>
	$(document).ready(function () {
		// Erste Kagegorie auswählen
		selectKategory(<?= $this->Kategorien[0]->ID; ?>);
		
<?php
			if (isset($_REQUEST["p_id"]) && $_REQUEST["p_id"] > 0)
			{
				echo "showProdukt(" . $_REQUEST["p_id"] . ")";
			}
?>
		
		// Filter changed
		$("#produkt_filter").on('input', function() {
			$.ajax({
				type: "POST",
				url: "index.php",
				data: "ajax=1&c=Product&a=GetProducts&kid=" + currentKatId + "&prod_name=" + $("#produkt_filter").val(),
				success: onKategoryData
			});
		});
		
	});
</script>